import { Goods } from '../../store/index.js';
let WxParse = require('../../wxParse/wxParse.js');
const goods = new Goods();
Page({
  data: {
    imgUrl: getApp().globalData.imgUrl,
    like: false,
    goods:[],
    tab: [
      { id: "0", text: "商品详情", selected: false },
      { id: "1", text: "商品评价", selected: true },
    ],
    imgUrls: [
      'http://deking008.gitee.io/zpimg/wximg/banner.png',
      'http://deking008.gitee.io/zpimg/wximg/banner2.png',
      'http://deking008.gitee.io/zpimg/wximg/banner.png'
    ],
    htmlstr:'<div>1</div>',
    indicatorDots: true,
    autoplay: true,
    interval: 5000,
    duration: 500,
    popin: false,
    sharepopin: false,
    selected: true,
    selected1: false
  },
  changlike: function () {
    this.setData({
      like: !this.data.like
    });
  },
  changetab: function (e) {
    var id = e.currentTarget.id;
    var tab = this.data.tab;
    var len = tab.length;
    for (var i = 0; i < len; i++) {
      if (tab[i].id == id) {
        tab[i].selected = true;
      } else {
        tab[i].selected = false;
      }
    }
    this.setData({
      tab: tab
    });
  },
  sharePop: function () {
    this.setData({
      sharepopin: !this.data.sharepopin
    });
  },
  getGoodsInfo(){
    var that = this;
    goods.getGoodsInfo((res)=>{
      // console.log()
      let content = res.result.content;
      WxParse.wxParse('content', 'html', content,that, 5);
      this.setData({
        "goods": res.result
      })
    },87)
  },
  dataInit(){
    this.getGoodsInfo();
  },
  selectGg: function (e) {
    this.setData({
      popin: !this.data.popin
    });
  },

  sharePopk: function () {
    this.setData({
      sharepopkin: !this.data.sharepopkin
    });
  },
  selectGg: function (e) {
    this.setData({
      popin: !this.data.popin
    });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.dataInit();

  },

})


